<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.12.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NeuZephyr: nz::nodes::calc::Col2ImgNode Class Reference</title>
<link rel="icon" href="NZ_logo2.png" type="image/x-icon" />
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="NZ_logo2.png"/></td>
  <td id="projectalign">
   <div id="projectname">NeuZephyr
   </div>
   <div id="projectbrief">Simple DL Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.12.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() { codefold.init(0); });
/* @license-end */
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function(){ initResizable(false); });
/* @license-end */
</script>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><b>nz</b></li><li class="navelem"><a class="el" href="namespacenz_1_1nodes.html">nodes</a></li><li class="navelem"><a class="el" href="namespacenz_1_1nodes_1_1calc.html">calc</a></li><li class="navelem"><a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html">Col2ImgNode</a></li>  </ul>
</div>
</div><!-- top -->
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="classnz_1_1nodes_1_1calc_1_1_col2_img_node-members.html">List of all members</a>  </div>
  <div class="headertitle"><div class="title">nz::nodes::calc::Col2ImgNode Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Reconstructs spatial tensors from column matrices generated by im2col transformation.  
 <a href="#details">More...</a></p>
<div class="dynheader">
Inheritance diagram for nz::nodes::calc::Col2ImgNode:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1nodes_1_1calc_1_1_col2_img_node__inherit__graph.png" border="0" usemap="#anz_1_1nodes_1_1calc_1_1_col2_img_node_inherit__map" alt="Inheritance graph"/></div>
<map name="anz_1_1nodes_1_1calc_1_1_col2_img_node_inherit__map" id="anz_1_1nodes_1_1calc_1_1_col2_img_node_inherit__map">
<area shape="rect" title="Reconstructs spatial tensors from column matrices generated by im2col transformation." alt="" coords="5,80,204,107"/>
<area shape="rect" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph." alt="" coords="46,5,163,32"/>
<area shape="poly" title=" " alt="" coords="107,48,107,80,102,80,102,48"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for nz::nodes::calc::Col2ImgNode:</div>
<div class="dyncontent">
<div class="center"><img src="classnz_1_1nodes_1_1calc_1_1_col2_img_node__coll__graph.png" border="0" usemap="#anz_1_1nodes_1_1calc_1_1_col2_img_node_coll__map" alt="Collaboration graph"/></div>
<map name="anz_1_1nodes_1_1calc_1_1_col2_img_node_coll__map" id="anz_1_1nodes_1_1calc_1_1_col2_img_node_coll__map">
<area shape="rect" title="Reconstructs spatial tensors from column matrices generated by im2col transformation." alt="" coords="5,80,204,107"/>
<area shape="rect" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph." alt="" coords="46,5,163,32"/>
<area shape="poly" title=" " alt="" coords="107,48,107,80,102,80,102,48"/>
</map>
<center><span class="legend">[<a href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a247f00c842e0420bac145f90c688a74a" id="r_a247f00c842e0420bac145f90c688a74a"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a247f00c842e0420bac145f90c688a74a">Col2ImgNode</a> (<a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *input, Tensor::size_type outputHeight, Tensor::size_type outputWidth)</td></tr>
<tr class="memdesc:a247f00c842e0420bac145f90c688a74a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor for the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a> class.  <br /></td></tr>
<tr class="separator:a247f00c842e0420bac145f90c688a74a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ae70df2f92889693ba699051af3de703f" id="r_ae70df2f92889693ba699051af3de703f"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#ae70df2f92889693ba699051af3de703f">forward</a> () override</td></tr>
<tr class="memdesc:ae70df2f92889693ba699051af3de703f"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the forward propagation operation in the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>.  <br /></td></tr>
<tr class="separator:ae70df2f92889693ba699051af3de703f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a372c237486b96cadfbc71fe7e3a16bdd" id="r_a372c237486b96cadfbc71fe7e3a16bdd"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="#a372c237486b96cadfbc71fe7e3a16bdd">backward</a> () override</td></tr>
<tr class="memdesc:a372c237486b96cadfbc71fe7e3a16bdd"><td class="mdescLeft">&#160;</td><td class="mdescRight">Performs the backward propagation operation in the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>.  <br /></td></tr>
<tr class="separator:a372c237486b96cadfbc71fe7e3a16bdd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classnz_1_1nodes_1_1_node"><td colspan="2" onclick="javascript:dynsection.toggleInherit('pub_methods_classnz_1_1nodes_1_1_node')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classnz_1_1nodes_1_1_node.html">nz::nodes::Node</a></td></tr>
<tr class="memitem:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a687ee9c34eb61f8f28caa201ca42696e"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a687ee9c34eb61f8f28caa201ca42696e">print</a> (std::ostream &amp;os) const</td></tr>
<tr class="memdesc:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Prints the type, data, and gradient of the node.  <br /></td></tr>
<tr class="separator:a687ee9c34eb61f8f28caa201ca42696e inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a9b85913e12422bb4ac2fff483427bb47"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a9b85913e12422bb4ac2fff483427bb47">dataInject</a> (Tensor::value_type *data, bool grad=false) const</td></tr>
<tr class="memdesc:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data into a relevant tensor object, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:a9b85913e12422bb4ac2fff483427bb47 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_a609f1730085dd1d31e0ddcbbae48a065"><td class="memTemplParams" colspan="2">template&lt;typename Iterator &gt; </td></tr>
<tr class="memitem:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memTemplItemLeft" align="right" valign="top">void&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#a609f1730085dd1d31e0ddcbbae48a065">dataInject</a> (Iterator begin, Iterator end, const bool grad=false) const</td></tr>
<tr class="memdesc:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data from an iterator range into the output tensor of the InputNode, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:a609f1730085dd1d31e0ddcbbae48a065 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node" id="r_af8b4bab3271df92ca1f0914f7a97b1e8"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classnz_1_1nodes_1_1_node.html#af8b4bab3271df92ca1f0914f7a97b1e8">dataInject</a> (const std::initializer_list&lt; Tensor::value_type &gt; &amp;data, bool grad=false) const</td></tr>
<tr class="memdesc:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="mdescLeft">&#160;</td><td class="mdescRight">Injects data from a std::initializer_list into the output tensor of the <a class="el" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph.">Node</a>, optionally setting its gradient requirement.  <br /></td></tr>
<tr class="separator:af8b4bab3271df92ca1f0914f7a97b1e8 inherit pub_methods_classnz_1_1nodes_1_1_node"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Reconstructs spatial tensors from column matrices generated by im2col transformation. </p>
<p>This node performs the inverse operation of <a class="el" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html" title="Implements im2col transformation for efficient convolution operations in neural networks.">Img2ColNode</a>, converting (N, 1, Hout*Wout, Cout) tensors back to (N, Cout, Hout, Wout) spatial format. Essential for gradient propagation in convolution operations and feature map reconstruction.</p>
<p>Core functionality and characteristics:</p><ul>
<li><b>Spatial Reconstruction</b>: Transforms column-organized data back to original spatial dimensions.</li>
<li><b>Gradient Handling</b>: Reconstructs gradients during backpropagation through reverse im2col.</li>
<li><b>Parameter Consistency</b>: Requires matching kernel/stride/padding with original <a class="el" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html" title="Implements im2col transformation for efficient convolution operations in neural networks.">Img2ColNode</a>.</li>
<li><b>Memory Optimization</b>: Implements efficient gradient summation for overlapping regions.</li>
<li><b>Shape Restoration</b>: Recovers original spatial dimensions through inverse indexing.</li>
<li><b>CUDA Support</b>: GPU-accelerated implementation for both forward and backward passes.</li>
</ul>
<p>Key implementation aspects:</p><ul>
<li><b>Forward Pass</b>: Reshapes column matrix to spatial format using output dimensions.</li>
<li><b>Backward Pass</b>: Applies im2col transformation to gradients for upstream propagation.</li>
<li><b>Overlap Resolution</b>: Accumulates gradients from overlapping input regions during backward pass.</li>
<li><b>Shape Validation</b>: Verifies input tensor conforms to (N, 1, H*W, C) structure.</li>
</ul>
<p>Typical use cases:</p><ul>
<li>Gradient computation for convolution layers using matrix-based implementations.</li>
<li>Feature map reconstruction after channel-wise operations.</li>
<li>Custom layer implementations requiring spatial/tensor format conversion.</li>
<li>Visualization of intermediate column-organized features.</li>
</ul>
<p>Critical considerations:</p><ul>
<li><b>Parameter Matching</b>: Must use identical kernel/stride/padding to corresponding <a class="el" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html" title="Implements im2col transformation for efficient convolution operations in neural networks.">Img2ColNode</a>.</li>
<li><b>Memory Footprint</b>: Gradient tensors may require significant memory during backward pass.</li>
<li><b>Input Constraints</b>: Strict 4D input tensor requirement with second dimension = 1.</li>
<li><b>Spatial Resolution</b>: Output dimensions must match original pre-im2col calculations.</li>
</ul>
<dl class="section warning"><dt>Warning</dt><dd><ul>
<li>Input tensor shape mismatch will cause runtime errors.</li>
<li>Incorrect kernel/stride parameters may produce distorted output spatial dimensions.</li>
<li>Large kernel sizes combined with small strides may create memory pressure during backward pass.</li>
</ul>
</dd></dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Output dimensions should satisfy: Hout = (H - K_h + 2*padding)/stride + 1</li>
<li>Backward pass internally uses <a class="el" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html" title="Implements im2col transformation for efficient convolution operations in neural networks.">Img2ColNode</a>'s logic for gradient propagation.</li>
<li>For dilated convolutions, ensure parameter compatibility with forward operations.</li>
</ul>
</dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html" title="Implements im2col transformation for efficient convolution operations in neural networks.">Img2ColNode</a> For the corresponding <a class="el" href="#ae70df2f92889693ba699051af3de703f" title="Performs the forward propagation operation in the Col2ImgNode.">forward</a> transformation </dd>
<dd>
ConvolutionNode For typical usage context in convolutional networks</dd></dl>
<h3><a class="anchor" id="autotoc_md108"></a>
Usage Example:</h3>
<div class="fragment"><div class="line"><span class="comment">// Previous im2col transformation</span></div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html">Img2ColNode</a> im2col(&amp;input, 3, 3, 1, 1);</div>
<div class="line">im2col.forward(); <span class="comment">// Output shape: (32, 1, 256*256, 64)</span></div>
<div class="line"> </div>
<div class="line"><span class="comment">// Reconstruct original spatial format</span></div>
<div class="line">Col2ImNode col2im(&amp;im2col, 3, 3, 1, 1);</div>
<div class="line">col2im.forward();</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Reconstructed shape: (32, 64, 256, 256)</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;Reconstructed shape: &quot;</span> &lt;&lt; col2im.output-&gt;shape() &lt;&lt; std::endl;</div>
<div class="line"> </div>
<div class="line"><span class="comment">// Backward pass through inverse transformation</span></div>
<div class="line">col2im.backward();</div>
<div class="ttc" id="aclassnz_1_1nodes_1_1calc_1_1_img2_col_node_html"><div class="ttname"><a href="classnz_1_1nodes_1_1calc_1_1_img2_col_node.html">nz::nodes::calc::Img2ColNode</a></div><div class="ttdoc">Implements im2col transformation for efficient convolution operations in neural networks.</div><div class="ttdef"><b>Definition</b> <a href="_nodes_8cuh_source.html#l03729">Nodes.cuh:3729</a></div></div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge (<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2023/10/18 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_nodes_8cuh_source.html#l03910">3910</a> of file <a class="el" href="_nodes_8cuh_source.html">Nodes.cuh</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a247f00c842e0420bac145f90c688a74a" name="a247f00c842e0420bac145f90c688a74a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a247f00c842e0420bac145f90c688a74a">&#9670;&#160;</a></span>Col2ImgNode()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">nz::nodes::calc::Col2ImgNode::Col2ImgNode </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classnz_1_1nodes_1_1_node.html">Node</a> *</td>          <td class="paramname"><span class="paramname"><em>input</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>outputHeight</em></span>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">Tensor::size_type</td>          <td class="paramname"><span class="paramname"><em>outputWidth</em></span>&#160;)</td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor for the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a> class. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">input</td><td>A pointer to the input <a class="el" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph.">Node</a> (host-to-object). This node provides the necessary input data for the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>. </td></tr>
    <tr><td class="paramname">outputHeight</td><td>The height of the output image in size_type (host-to-object). </td></tr>
    <tr><td class="paramname">outputWidth</td><td>The width of the output image in size_type (host-to-object).</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This constructor initializes a <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a> object. It sets the output height, width, and number of channels based on the input node's output shape. It then adds the input node to the list of input nodes. A new Tensor object is created for the output, with its shape determined by the batch size from the input node's output, the number of output channels, the specified output height, and width. The output tensor also inherits the gradient requirement from the input node's output. Finally, the node type is set to "Col2Img".</p>
<p>Memory management strategy: The constructor uses <code>std::make_shared</code> to allocate memory for the output tensor. The memory will be automatically managed by the smart pointer, and it will be released when the last reference to the tensor is removed. Exception handling mechanism: There is no explicit exception handling in this constructor. However, if memory allocation for the output tensor fails, a <code>std::bad_alloc</code> exception may be thrown.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">std::bad_alloc</td><td>If memory allocation for the output tensor fails.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the input pointer is valid and points to a properly initialized <a class="el" href="classnz_1_1nodes_1_1_node.html" title="Base class for nodes in a neural network or computational graph.">Node</a> object.</li>
<li>The performance of this constructor is mainly determined by the memory allocation for the output tensor, which has a time complexity of O(n), where n is the number of elements in the output tensor.</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1_node.html">Node</a>* inputNode = <span class="keyword">new</span> <a class="code hl_class" href="classnz_1_1nodes_1_1_node.html">Node</a>();</div>
<div class="line">Tensor::size_type outputHeight = 10;</div>
<div class="line">Tensor::size_type outputWidth = 10;</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html">Col2ImgNode</a> col2ImgNode(inputNode, outputHeight, outputWidth);</div>
<div class="line">```</div>
<div class="ttc" id="aclassnz_1_1nodes_1_1_node_html"><div class="ttname"><a href="classnz_1_1nodes_1_1_node.html">nz::nodes::Node</a></div><div class="ttdoc">Base class for nodes in a neural network or computational graph.</div><div class="ttdef"><b>Definition</b> <a href="_nodes_8cuh_source.html#l00114">Nodes.cuh:114</a></div></div>
<div class="ttc" id="aclassnz_1_1nodes_1_1calc_1_1_col2_img_node_html"><div class="ttname"><a href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html">nz::nodes::calc::Col2ImgNode</a></div><div class="ttdoc">Reconstructs spatial tensors from column matrices generated by im2col transformation.</div><div class="ttdef"><b>Definition</b> <a href="_nodes_8cuh_source.html#l03910">Nodes.cuh:3910</a></div></div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00642">642</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a372c237486b96cadfbc71fe7e3a16bdd" name="a372c237486b96cadfbc71fe7e3a16bdd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a372c237486b96cadfbc71fe7e3a16bdd">&#9670;&#160;</a></span>backward()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::nodes::calc::Col2ImgNode::backward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs the backward propagation operation in the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This function conducts the backward propagation step for the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>. It first checks if the output tensor of the input node requires gradient computation. If it does, the function calls <code>iCol2imgBackward</code>, passing the gradient tensor of the input node's output, the gradient tensor of the output, the output height, output width, output channels, and the batch size from the input node's output. The <code>iCol2imgBackward</code> function is responsible for computing the gradients and propagating them back to the input.</p>
<p>Memory management strategy: This function does not allocate or deallocate any memory directly. It operates on the existing gradient tensors of the input and output. Exception handling mechanism: There is no explicit exception handling in this function. If the <code>iCol2imgBackward</code> function encounters an error, it may throw an exception, and the specific type of exception depends on the implementation of <code>iCol2imgBackward</code>.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">[Exception</td><td>type from iCol2imgBackward] If the <code>iCol2imgBackward</code> function encounters an error during execution.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the gradient tensors of the input node's output and the output tensor of the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a> are properly initialized before calling this function.</li>
<li>The performance of this function depends on the implementation of the <code>iCol2imgBackward</code> function. If the <code>iCol2imgBackward</code> function has a time complexity of O(n), where n is the number of elements in the input or output gradient tensors, then this backward propagation step also has a time complexity of O(n).</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html">Col2ImgNode</a> col2ImgNode(...); <span class="comment">// Assume Col2ImgNode is properly initialized</span></div>
<div class="line">col2ImgNode.backward();</div>
<div class="line">```</div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p>Implements <a class="el" href="classnz_1_1nodes_1_1_node.html#a0a9ecbaa3d790ba38e8218aca7837fd0">nz::nodes::Node</a>.</p>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00660">660</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<a id="ae70df2f92889693ba699051af3de703f" name="ae70df2f92889693ba699051af3de703f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ae70df2f92889693ba699051af3de703f">&#9670;&#160;</a></span>forward()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void nz::nodes::calc::Col2ImgNode::forward </td>
          <td>(</td>
          <td class="paramname"><span class="paramname"><em></em></span></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">override</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Performs the forward propagation operation in the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">None</td><td></td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>None</dd></dl>
<p>This function executes the forward propagation step for the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a>. It calls the <code>iCol2img</code> function, passing the output tensor's data, the input node's output tensor's data, the output height, output width, output channels, and the batch size from the input node's output. The <code>iCol2img</code> function is responsible for converting the column - formatted data from the input to image - formatted data in the output.</p>
<p>Memory management strategy: This function does not allocate or deallocate any memory directly. It operates on the existing data pointers of the input and output tensors. Exception handling mechanism: There is no explicit exception handling in this function. If the <code>iCol2img</code> function encounters an error, it may throw an exception, but the nature of the exception depends on the implementation of <code>iCol2img</code>.</p>
<dl class="exception"><dt>Exceptions</dt><dd>
  <table class="exception">
    <tr><td class="paramname">[Exception</td><td>type from iCol2img] If the <code>iCol2img</code> function encounters an error during execution.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd><ul>
<li>Ensure that the input node's output tensor and the output tensor of the <a class="el" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html" title="Reconstructs spatial tensors from column matrices generated by im2col transformation.">Col2ImgNode</a> are properly initialized before calling this function.</li>
<li>The performance of this function depends on the implementation of the <code>iCol2img</code> function. If the <code>iCol2img</code> function has a time complexity of O(n), where n is the number of elements in the input or output tensors, then this forward propagation step also has a time complexity of O(n).</li>
</ul>
</dd></dl>
<div class="fragment"><div class="line">```cpp</div>
<div class="line"><a class="code hl_class" href="classnz_1_1nodes_1_1calc_1_1_col2_img_node.html">Col2ImgNode</a> col2ImgNode(...); <span class="comment">// Assume Col2ImgNode is properly initialized</span></div>
<div class="line">col2ImgNode.forward();</div>
<div class="line">```</div>
</div><!-- fragment --><dl class="section author"><dt>Author</dt><dd>Mgepahmge(<a href="https://github.com/Mgepahmge">https://github.com/Mgepahmge</a>)</dd></dl>
<dl class="section date"><dt>Date</dt><dd>2024/07/15 </dd></dl>

<p>Implements <a class="el" href="classnz_1_1nodes_1_1_node.html#a8a828c2e91a4aa2a9ab7b94554e4685b">nz::nodes::Node</a>.</p>

<p class="definition">Definition at line <a class="el" href="_nodes_8cu_source.html#l00655">655</a> of file <a class="el" href="_nodes_8cu_source.html">Nodes.cu</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/include/NeuZephyr/<a class="el" href="_nodes_8cuh_source.html">Nodes.cuh</a></li>
<li>D:/Users/Mgepahmge/Documents/C Program/NeuZephyr/src/<a class="el" href="_nodes_8cu_source.html">Nodes.cu</a></li>
</ul>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.12.0
</small></address>
</div><!-- doc-content -->
</body>
</html>
